import Vue from 'vue'
import Vuex from 'vuex'
import category from '@/store/modules/category'
import newlist from '@/store/modules/newlist'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    category,
    newlist
  },
  getters: {
    // 建立数据的快捷访问
    category: state => state.category.category,
    currentCategory: state => state.category.currentCategory,
    // 避免因没有数据导致错误
    // 当前新闻内容
    currentList: state => state.newlist.alldata[state.category.currentCategory] || []
  }
})
